#!/usr/bin/env bash
#
#    Linie - Install Internet Explorer on Linux <raghu.kb@gmail.com>
#
#    Copyright (C) 2010 Raghu Kaippully
#
#    This program is free software; you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation; either version 2 of the License, or
#    (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with this program; if not, write to the Free Software
#    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA


# Install IE7
echo -e "[ Installing IE7 ]\n"

FILESDIR=${LINIE}/files/ie7

# Setup WINEPREFIX
export WINEPREFIX=${BASEDIR}/ie7
mkdir -p ${WINEPREFIX}

# Download required components
mkdir -p ${DOWNLOADDIR}

download IE7-WindowsXP-x86-enu.exe "http://download.microsoft.com/download/3/8/8/38889dc1-848c-4bf2-8335-86c573ad86d9/IE7-WindowsXP-x86-enu.exe"
cd ${DOWNLOADDIR}
md5sum -c ${FILESDIR}/ie7.files

# Install basic components with winetricks
log_info "Adding common components..."
winetricks -q comctl32 comctl32.ocx corefonts gdiplus gecko msls31 msxml3 msxml4 msxml6 riched20 riched30 tahoma

# Load the registry settings
log_info "Setting up wine registry..."
wine regedit ${FILESDIR}/ie7.reg |& debugfilter

# Install IE7
log_info "Installing IE7..."
wine IE7-WindowsXP-x86-enu.exe /quiet |& debugfilter

# Simulate restart
log_info "Restarting wine..."
wineboot -k |& debugfilter

# Create shortcuts
mkdir -p ${HOME}/bin
cat > ${HOME}/bin/ie7 << EOF
#!/usr/bin/env bash
WINEPREFIX=${WINEPREFIX} wine 'C:/Program Files/Internet Explorer/iexplore.exe' &> /dev/null
EOF
chmod +x ${HOME}/bin/ie7

echo "Installation complete. Start your IE using ${HOME}/bin/ie7"
